/**
 *@program: getx_simple_code
 *@description:
 *@author: Ming
 *@create: 2023-12-28 14:03
 *@version v1.0
 */
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class BaseFunView extends StatelessWidget {
  const BaseFunView({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("基本功能"),
        ),
        body: ListView(
          children: [
            ListTile(
              title: Text("Snackbar"),
              subtitle: Text('Get.snackbar()'),
              onTap: () => Get.snackbar("Snackbar 标题", "欢迎使用Snackbar"),
            ),
            Divider(),
            ListTile(
              title: Text("Dialog"),
              subtitle: Text('Get.defaultDialog()'),
              onTap: () => {
                Get.defaultDialog(
                  title: '我是标题',
                  middleText: '我是内容',
                  textConfirm: "确定",
                  textCancel: '取消',
                  onConfirm: () => {print('点击确定按钮'), Get.back()},
                ),
              },
            ),
            Divider(),
            ListTile(
              title: Text("BottomSheet"),
              subtitle: Text('Get.bottomSheet()'),
              onTap: () => {
                Get.bottomSheet(Container(
                  color: Get.isDarkMode ? Colors.black26 : Colors.white,
                  height: 200,
                  child: Column(
                    children: [
                      ListTile(
                        leading: Icon(Icons.wb_sunny_outlined,
                            color:
                                Get.isDarkMode ? Colors.white : Colors.black87),
                        onTap: () {
                          //切换主题
                          Get.changeTheme(ThemeData.light());
                          Get.back();
                        },
                        title: Text(
                          "白天模式",
                          style: TextStyle(
                              color: Get.isDarkMode
                                  ? Colors.white
                                  : Colors.black87),
                        ),
                      ),
                      ListTile(
                        leading: Icon(Icons.wb_sunny,
                            color:Get.isDarkMode ? Colors.white : Colors.black87),
                        onTap: () {
                          //切换主题
                          Get.changeTheme(ThemeData.dark());
                          Get.back();
                        },
                        title: Text(
                          "夜晚模式",
                          style: TextStyle(
                              color: Get.isDarkMode
                                  ? Colors.white
                                  : Colors.black87),
                        ),
                      )
                    ],
                  ),
                ))
              },
            ),
            Divider(),
          ],
        ));
  }
}
